//
//  ICRedPacketNetworkManager.m
//  ICome
//
//  Created by 席鹏飞 on 2016/11/21.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICRedPacketNetworkManager.h"
#import "ICHeaderFile.h"

@implementation ICRedPacketNetworkManager

+(instancetype)sharedInstance {
    static ICRedPacketNetworkManager *manager;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        manager = [[ICRedPacketNetworkManager alloc] init];
    });
    return manager;
}

// 检查红包密码是否已设置
- (void)checkRedPacketPasswordWithParam:(NSDictionary *)param
                                success:(void (^)(id object))success
                                failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_CHECKPASSWORD];
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 设置或修改红包密码
- (void)setRedPacketPasswordWithParam:(NSDictionary *)param
                              success:(void (^)(id object))success
                              failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_SETPASSWORD];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 发送红包
- (void)sendRedPacketWithParam:(NSDictionary *)param
                       success:(void (^)(id object))success
                       failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_SENDREDPACKET];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 点击红包
- (void)clickRedPacketWithParam:(NSDictionary *)param
                        success:(void (^)(id object))success
                        failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_CLICKREDPACKET];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 点击"启"
- (void)clickOpenWithParam:(NSDictionary *)param
                   success:(void (^)(id object))success
                   failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_CLICKOPEN];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 看看大家
- (void)lookListWithParam:(NSDictionary *)param
                  success:(void (^)(id object))success
                  failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_LOOKLIST];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

// 我的红包流水
- (void)myHistoryListWithParam:(NSDictionary *)param
                       success:(void (^)(id object))success
                       failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:REDPACKET_MYHISTORYLIST];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

@end
